cmake_minimum_required(VERSION 3.1.3)
project(mqclient)
set(CMAKE_CXX_STANDARD 14)

# 添加库文件搜索路径
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_part/lib)

# 设置可执行文件的输出目录
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# 检查并创建输出目录
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})

# 搜集所有的源文件
set(SRC_LIST 
    ../mqcomm/protocol.pb.cc 
    ../mqcomm/Message.pb.cc 
    ../third_part/include/muduo/protobuf/codec.cc
)

# 添加可执行文件
add_executable(publish_client publish_client.cpp ${SRC_LIST})
add_executable(consumer_client consumer_client.cpp ${SRC_LIST})

# 添加头文件搜索路径
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_part/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)

# 链接第三方库
target_link_libraries(publish_client 
    muduo_net 
    muduo_base 
    pthread
    protobuf 
    z
)

target_link_libraries(consumer_client 
    muduo_net 
    muduo_base 
    pthread
    protobuf 
    z
)